package com.zzptc.myk.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.zzptc.myk.myapplication.entity.Lisi;
import com.zzptc.myk.myapplication.service.LIsiService;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getLisi();
    }

    private void getLisi() {
        Retrofit r=new Retrofit.Builder()
                .baseUrl("http://api.juheapi.com/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        LIsiService lIsiService = r.create(LIsiService.class);
        Call<Lisi> a = lIsiService.getAll("f6977ebf47fb124ac297deb06aacce9d", "1.0",12,3);
        a.enqueue(new Callback<Lisi>() {
            @Override
            public void onResponse(Call<Lisi> call, Response<Lisi> response) {
                Lisi body = response.body();
                Log.d(TAG, "onResponse: "+body.getResult().get(1).getDes());
            }

            @Override
            public void onFailure(Call<Lisi> call, Throwable t) {
                Log.d(TAG, "onFailure: "+t.getMessage());
            }
        });
    }
}
